package com.CusterRelSys.control;

import com.CusterRelSys.entity.CstCustomer;
import com.CusterRelSys.mapper.CstSustomerMapperMWJ;
import com.CusterRelSys.service.ICstSustomerServiceMWJ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by MWJ on 2017/12/1.
 */
@Controller
@RequestMapping("/CstSustomer")
public class CstSustomerControllerMWJ {
    @Autowired
    private ICstSustomerServiceMWJ iCstSustomerServiceMWJ;

    /**
     * 查询不重复的地区
     * @return
     */
    @RequestMapping("/selectSingleCustRegion")
    public @ResponseBody List<String> selectSingleCustRegion(){
        List<String> strRegion = this.iCstSustomerServiceMWJ.selectSingleCustRegion();
        return strRegion;
    }

    /**
     * 查询不重复的客户等级
     * @return
     * CusServiceServiceImpl
     */
    @RequestMapping("/selectSingleCustLevel")
    public @ResponseBody List<String> selectSingleCustLevel(){
        List<String> strLevel = this.iCstSustomerServiceMWJ.selectSingleCustLevel();
        return strLevel;
    }

    /**
     * 查询不重复的经理
     * @return
     */
    @RequestMapping("/selectSingleCustManageName")
    public @ResponseBody List<String> selectSingleCustManageName(){
        List<String> strManage = this.iCstSustomerServiceMWJ.selectSingleCustManageName();
        return strManage;
    }

    /**
     * 查询不重复的客户满意度
     * @return
     */
    @RequestMapping("/selectSingleCustSatisfy")
    public @ResponseBody List<String> selectSingleCustSatisfy(){
        List<String> strSatisfy = this.iCstSustomerServiceMWJ.selectSingleCustSatisfy();
        return strSatisfy;
    }

    /**
     * 查询不重复的客户信誉度
     * @return
     */
    @RequestMapping("/selectSingleCustCredit")
    public @ResponseBody List<String> selectSingleCustCredit(){
        List<String> strCredit = this.iCstSustomerServiceMWJ.selectSingleCustCredit();
        return strCredit;
    }

    /**
     * 通过页面条件查询所有符合条件的客户信息
     * @return
     */
    @RequestMapping("/selectByCondition")
    public @ResponseBody List<CstCustomer> selectByCondition(CstCustomer cstSustomer) {
        List<CstCustomer> conditionCust = this.iCstSustomerServiceMWJ.selectByCondition(cstSustomer);
        return conditionCust;
    }

    /**
     * 通过custNo查询当前用户的所有信息
     * @return
     */
    @RequestMapping("/selectByCustNo")
    public @ResponseBody List<CstCustomer> selectByCustNo(String custNo) {
        List<CstCustomer> byCustNo = this.iCstSustomerServiceMWJ.selectByCustNo(custNo);
        return byCustNo;
    }

    @RequestMapping("/updateCustomer")
    public @ResponseBody int updateCustomer(CstCustomer cstSustomer){
        int i = this.iCstSustomerServiceMWJ.updateCustomer(cstSustomer);
        return i;
    }
}
